<template>
    <section>
        <div class="top">
            <p class="pic"></p>
            <div class="txt">
                <p>蘑菇街 总有高手帮你挑</p>
                <div>
                    <p class="start">
                        <span v-for="n in 5"></span>
                    </p>
                    <span class="over-user">超过2亿用户已下载</span>
                </div>
            </div>
            <button>打开APP</button>
        </div>
        <topNav></topNav>
        <div class="home-swiper">
            <swiper ref="mySwiper" :options="swiperOption" v-if="banners.length>0">
                <swiper-slide :key="banner" v-for="banner in banners">
                    <img :src="banner" />
                </swiper-slide>
                <div class="swiper-pagination" slot="pagination"></div>
            </swiper>
        </div>
        <ul class="type">
            <li v-for="(typeList,index) in typeLists">
                <router-link :to="'/detail/'+index+'/'+typeList.title">
                    <p>
                        <img :src="typeList.pic" />
                    </p>
                    <span>{{typeList.title}}</span>
                </router-link>
            </li>
        </ul>
        <ul class="dynamic">
            <li v-for="(dynamicList,index) in dynamicLists">
                <div class="wrap">
                    <img v-lazy="dynamicList.conImg" />
                </div>
                <p>{{dynamicList.title}}</p>
                <mt-cell v-show="dynamicList.flag" :title="dynamicList.tag">
                    <img slot="icon" src="../../assets/images/home-sign.webp" />
                </mt-cell>
                <div class="person">
                    <p>
                        <img :src="dynamicList.perImg" />
                    </p>
                    <span>{{dynamicList.perName}}</span>
                </div>
            </li>
        </ul>
    </section>
</template>

<script>
import topNav from "../common/nav";
export default {
    components: {
        topNav
    },
    data() {
        return {
            typeLists: [],
            dynamicLists: [],
            // 轮播图的数据
            banners: [],
            // 轮播图的配置
            swiperOption: {
                autoplay: {
                    delay: 2000,
                    disableOnInteraction: false
                },
                pagination: {
                    el: ".swiper-pagination",
                    type: "bullets"
                },
                loop: true
            }
        };
    },
    mounted() {
        this.$http.get("./data/home.json").then(res => {
            this.banners = res.data.banners;
            this.typeLists = res.data.type;
            this.dynamicLists = res.data.dynamic;
        });
    }
};
</script>



<style scoped lang="scss">
$theme-color: #ff0176;
$border-color: rgb(216, 216, 216);
.top {
    display: flex;
    padding: 8px 15px;
    align-items: center;
    border-bottom: 1px solid $border-color;
    .pic {
        width: 30px;
        height: 30px;
        margin-right: 10px;
        background-image: url("../../assets/images/logo_60x60.png");
        background-size: contain;
    }
    .txt {
        line-height: 10px;
        & > p {
            font-size: 13px;
            line-height: 15px;
        }
        .start {
            display: inline-block;
            font-size: 0px;
            span {
                display: inline-block;
                width: 8px;
                height: 8px;
                margin-right: 4px;
                background: url("../../assets/images/start.png") no-repeat
                    center/cover;
            }
        }
        .over-user {
            font-size: 10px;
            color: grey;
        }
    }

    button {
        background-color: $theme-color;
        border: none;
        height: 100%;
        margin-left: auto;
        padding: 3px 10px;
        color: white;
        font-size: 12px;
        border-radius: 3px;
    }
}

.type {
    // margin:5px 15px;
    display: flex;
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    li {
        text-align: center;
        width: 20%;
        margin-bottom: 12px;
        a{
            text-decoration: none;
        }
        p {
            width: 50px;
            height: 50px;
            display: inline-block;
            img {
                width: 100%;
            }
        }
        span {
            display: block;
            font-size: 12px;
            color: rgb(90, 90, 90);
        }
    }
}

.dynamic {
    padding: 0px 10px 50px;
    column-count: 2;
    column-gap: 10px;

    li {
        height: 100%;
        overflow: auto;
        width: 100%;
        .wrap {
            img {
                border-radius: 5px 5px 0 0;
                width: 100%;
            }
        }
        .person {
            margin: 10px 0;
            p {
                display: inline-block;
                width: 25px;
                img {
                    width: 100%;
                    border-radius: 50%;
                    vertical-align: middle;
                }
            }
            span {
                font-size: 10px;
                font-weight: 600;
            }
        }
    }
}
</style>



<style lang="scss">
$theme-color: #ff0176;
.home-swiper {
    .swiper-container {
        width: 100%;
        height: 34.6%;
        img {
            width: 100%;
        }
        & > .swiper-pagination-bullets {
            text-align: left;
            bottom: 7px;
            .swiper-pagination-bullet {
                width: 6px;
                height: 6px;
                opacity: 1;
                margin: 0px 5px;
                background-color: white;
            }
            .swiper-pagination-bullet-active {
                background-color: #d43e2e;
            }
        }
    }
}

.dynamic {
    li {
        & > p {
            margin-top: 10px;
            margin-bottom: 6px;
            font-size: 12px;
            color: grey;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            line-clamp: 2;
        }
        .mint-cell {
            min-height: 0px;
            display: inline-block;
        }

        .mint-cell-title {
            font-size: 10px;
            color: $theme-color;
            img {
                width: 8px;
                height: 12px;
            }
        }
        .mint-cell-wrapper {
            background-image: none;
            padding: 0 10px;
            min-height: 18px;
            background-color: #fff0f3;
        }
    }
    img[lazy="loading"] {
        display: block;
        width: 50px !important;
        height: 50px !important;
        margin: 0 auto;
    }
}
</style>